package com.owner.demo.springbootdemo.CircuitBreaker;

public class CircuitBreakerConfig {

    /**
     * closed状态的失败次数阈值
     */
    private int failThreshold = 50;

    /**
     * closed状态的失败计数的时间窗口
     */
    private int failCountWindowInMs = 50*1000;

    /**
     * 处于open状态下的延时时间
     */
    private int openTimeoutInMs = 5*1000;

    private CircuitBreakerConfig(){

    }

    public static CircuitBreakerConfig instanceDefault(){
        CircuitBreakerConfig config = new CircuitBreakerConfig();
        return config;
    }

    public static CircuitBreakerConfig instance(int failThreshold, int failCountWindowInMs, int openTimeoutInMs) {
        CircuitBreakerConfig config = new CircuitBreakerConfig();
        config.setFailThreshold(failThreshold);
        config.setFailCountWindowInMs(failCountWindowInMs);
        config.setOpenTimeoutInMs(openTimeoutInMs);
        return config;
    }

    public int getFailThreshold() {
        return failThreshold;
    }

    public void setFailThreshold(int failThreshold) {
        this.failThreshold = failThreshold;
    }

    public int getFailCountWindowInMs() {
        return failCountWindowInMs;
    }

    public void setFailCountWindowInMs(int failCountWindowInMs) {
        this.failCountWindowInMs = failCountWindowInMs;
    }

    public int getOpenTimeoutInMs() {
        return openTimeoutInMs;
    }

    public void setOpenTimeoutInMs(int openTimeoutInMs) {
        this.openTimeoutInMs = openTimeoutInMs;
    }
}